 function delimg(obj,img,todo) {
	if (confirm("是否删该图片？\n\n确定->删除\n\n取消->不删除"))
	{
		if(todo == 'todo'){
			$.post(
			  "del_img.php",
			  {onlyimg:'imgss',imgurl:img},
			  function(data){
				if(data==1){
					 $(obj).parent().parent().remove();
				}
			  },
			  'json'
			)
		}else{
			$.post(
			  "del_img.php",
			  {imgurl:img},
			  function(data){
					if(data==1){
					   $(obj).parent().parent().remove();
					}
			  },
			  'json'
			)
		}
	}
}
var  swfurl   = "../js/swf/swfupload.swf";
var  phpurl    = "upload.php";
var  phpurl2    = "upload2.php";
var  buttonurl ="";
var  conurl    = "../upload/product/";
var  conurl2    = "../upload/productimg/";
var upload1, upload2;
window.onload = function() {
	upload1 = new SWFUpload({
	   upload_url: phpurl,
		post_params: {"PHPSESSID" : "gjc0to5amsgd23p3klaurifuq1"},
		file_size_limit : "1024",	// 200 kb
		file_types : "*.jpg;*.gif;*.png",
		file_types_description : "Image Files",
		file_upload_limit : "0",
		file_queue_limit : "0",
		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_start_handler : uploadStart,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSucces,
		upload_complete_handler : uploadComplete,
		queue_complete_handler : queueComplete,
		button_image_url : buttonurl,
		button_placeholder_id : "upload_id",
		button_width: "88",
		button_height: "26",
		button_text: '上传',
		button_text_style: ".theFont {font-size: 16;z-index=0;}",
		button_text_left_padding: 30,
		button_text_top_padding: 10,
		flash_url : swfurl,
		 swfupload_element_id : "flashUI2",
		degraded_element_id : "degradedUI2",
		custom_settings : {
				progressTarget : "fsUploadProgress1",
				cancelButtonId : "btnCancel1"
		},
		debug: false
	});
	upload2 = new SWFUpload({
			upload_url: phpurl2,
			post_params: {"PHPSESSID" : "gjc0to5amsgd23p3klaurifuq2"},
			file_size_limit : "1024",	// 200 kb
			file_types : "*.jpg;*.gif;*.png",
			file_types_description : "Image Files",
			file_upload_limit : "0",
			file_queue_limit : "0",
			file_queued_handler : fileQueued,
			file_queue_error_handler : fileQueueError,
			file_dialog_complete_handler : fileDialogComplete,
			upload_start_handler : uploadStart,
			upload_progress_handler : uploadProgress,
			upload_error_handler : uploadError,
			upload_success_handler : uploadSucces2,
			upload_complete_handler : uploadComplete,
			queue_complete_handler : queueComplete,
			button_image_url : buttonurl,
			button_placeholder_id : "upload_id2",
			button_width: "88",
			button_height: "26",
			button_text: '上传图片',
			button_text_style: ".theFont {font-size: 16; z-index=0;}",
			button_text_left_padding: 30,
			button_text_top_padding: 10,
			flash_url : swfurl,
			swfupload_element_id : "flashUI2",
			degraded_element_id : "degradedUI2",
			custom_settings : {
					progressTarget : "fsUploadProgress2",
					cancelButtonId : "btnCancel2"
			},
			debug: false
		});
}

function fileQueued(file) {
	var progress = new FileProgress(file, this.customSettings.progressTarget);
	progress.setStatus("正在等待...");
	progress.toggleCancel(true, this);
}
function fileQueueError(file, errorCode, message) {
}
function fileDialogComplete(numFilesSelected, numFilesQueued) {
	if (numFilesSelected > 0) {
			document.getElementById(this.customSettings.cancelButtonId).disabled = false;
	}
	this.startUpload();
}
function uploadStart(file) {
	var progress = new FileProgress(file, this.customSettings.progressTarget);
	progress.setStatus("正在上传...");
	progress.toggleCancel(true, this);
	return true;
}
function uploadProgress(file, bytesLoaded, bytesTotal) {
	var percent = Math.ceil((bytesLoaded / bytesTotal) * 100);
	var progress = new FileProgress(file, this.customSettings.progressTarget);
	progress.setProgress(percent);
	progress.setStatus("正在上传...");
}

function uploadSucces(file, serverData) {
	var progress = new FileProgress(file, this.customSettings.progressTarget);
	progress.setComplete();
	progress.setStatus("上传成功");
	progress.toggleCancel(false);
		var larg_box='<div class="img_box"><img id="jcrop_img"  src="'+conurl+serverData+'"/><input type="hidden"  name="logo" size="40" value="'+serverData+'"/></div>';
	$("#logo_box").empty().append(larg_box);
}

 function uploadSucces2(file, serverData) {
	var progress = new FileProgress(file, this.customSettings.progressTarget);
	progress.setComplete();
	progress.setStatus("上传成功");
	progress.toggleCancel(false);
	var myDate = new Date();
	 var list_item='<div class="product_img_box" id=img_box_byi'+myDate.getTime()+'><img  src='+conurl2+serverData+' /><div class="img_title"><span class="del_text"  onclick=cut_img("img_box_byi'+myDate.getTime()+'","'+conurl2+serverData+'")>裁切</span>&nbsp;<span class="del_text" onclick=delimg(this,"'+serverData+'","0")>删除</span></div><input  name="product_imgs[]" type="hidden" value="'+serverData+'"/></div>';
	 $("#product_img_list").append(list_item);
}

function uploadError(file, errorCode, message) {
}
function uploadComplete(file) {
	if (this.getStats().files_queued === 0) {
			document.getElementById(this.customSettings.cancelButtonId).disabled = true;
	}
}
function queueComplete(numFilesUploaded) {
	//	var status = document.getElementById("divStatus");
	//	status.innerHTML = numFilesUploaded + " 个文件" + (numFilesUploaded === 1 ? "" : "s") + "已上传.";
}



